package com.tedu.egmvcboot.config;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;


@Configuration
@MapperScan("com.tedu.egmvcboot.mapper")
@EnableSwagger2WebMvc
public class Config {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select().apis(RequestHandlerSelectors.basePackage("com.tedu.egmvcboot.controller"))//指定要扫描的Controller包
                .paths(PathSelectors.any())//对Controller中所有的路径生成接口文档
                .build();
    }
    public ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                        .title("两年半的练习项目")// 标题
                        .description("两年半的练习项目在线文档")// 描述
                        .version("1.0")// 版本号
                        .contact(new Contact("君子兰","www.huawei.com","2170316968@qq.com"))// 联系方式
                        .build();// 生成
    }
}
